<template>
  <div class="icons">
    <swiper :options="swiperOption">
      <div class="swiper-pagination" slot="pagination"></div>
      <!-- slides -->
      <swiper-slide v-for="(page, index) in pages" :key="index">
        <div class="icon" v-for="icon in page" :key="icon.id">
          <div class="icon-img"><img :src="icon.imgUrl" alt=""></div>
          <p class="icon-text">{{icon.desc}}</p>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>
<script>
export default {
  name: "Icons",
  data() {
    return {
      swiperOption: {
        // autoplay: false
      }
    }
  },
  props: {
    list: Array
  },
  computed: {
    pages() {
      let pages = [];
      this.list.forEach((item, index) => {
        let page = Math.floor(index / 8);
        if (!pages[page]) {
          pages[page] = [];
        }
        pages[page].push(item);
      });
      return pages;
    }
  }
};
</script>
<style lang="scss" scoped>
@import "~styles/varibles.scss";
// .icons >>> .swiper-container {
//   height: 0;
//   padding-bottom: 50%;
// }
.icons {
  overflow: hidden;
  // background-color: #eee;
  .icon {
    float: left;
    width: 25%;
    padding-bottom: 25%;
    position: relative;
    .icon-img {
      position: absolute;
      top: 0;
      bottom: 0.45rem;
      right: 0;
      left: 0;
      font-size: 0;
      text-align: center;
      padding-top: 0.2rem;
      box-sizing: border-box;
      img {
        max-width: 100%;
        max-height: 100%;
      }
    }
    .icon-text {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0.15rem;
      text-align: center;
      color: $baseFontColor;
      height: 0.45rem;
      line-height: 0.45rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}
</style>


